global keepers1960 ""

/* TH: It seems that previous code has written directly back to our source data */
/* file so this file already has our generated variables defined. I drop them here */
/* and recreate them to ensure that any code changes are propagated to the data */
/* that we use for analysis. I apply this rule to all source data sets, below, */
/* as relevant. */

drop income income3 vote_ce vote_gov pid_ce

numlabel, add

genl yr=1960
global keepers1960 $keepers1960 yr

genl id=v4
global keepers1960 $keepers1960 id

genl income=v21
replace income=v22 if v21==99
genl income3=income
centile income, c(33 66 100)
replace income3=0 if income<=r(c_1)
centile income, c(33 66 100)
replace income3=1 if income>r(c_1) & income<=r(c_2)
centile income, c(33 66 100)
replace income3=2 if income>r(c_2) & income<=r(c_3)
global keepers1960 $keepers1960 income3

genl pid_ce=(v147==2 & v148==1)
replace pid_ce=. if v147==.
global keepers1960 $keepers1960 pid_ce

genl pid_gov=pid_ce
global keepers1960 $keepers1960 pid_gov

genl vote_ce=v147
recode vote_ce 2=1 .=. else=0
global keepers1960 $keepers1960 vote_ce

genl vote_gov=vote_ce
global keepers1960 $keepers1960 vote_gov


genl gpi=abs(v97-4)/3
global keepers1960 $keepers1960 gpi

genl socref=v91
recode socref 8=3
replace socref=abs(socref-5)/4
global keepers1960 $keepers1960 socref

genl degree=v192
recode degree 6=1 1/5=0
global keepers1960 $keepers1960 degree


// Class/occupation

gen class_reho_3cat = v193
recode class_reho_3cat 1/7=3 10/24=2 30/40=1
label variable class_reho_3cat "Social class (3 cats.): higher value is higher class"
*label define LblClassGrade 1 "A: (Higher man.; prof." 2 "B: Lower man.; admin." 3 "C1A: Skilled; supervis. non-manu." 4 "C1B: Lower non-manu." 5 "C2: Skilled manu." 6 "D: Unskilled manu."
*label values class_head_grade LblClassGrade
global keepers1960 $keepers1960 class_reho_3cat

gen class_husb_3cat = v202
recode class_husb_3cat 1/7=3 10/25=2 30/40=1 0=. 99=.
label variable class_husb_3cat "Social class (3 cats.): higher value is higher class"
*label define LblClassGrade 1 "A: (Higher man.; prof." 2 "B: Lower man.; admin." 3 "C1A: Skilled; supervis. non-manu." 4 "C1B: Lower non-manu." 5 "C2: Skilled manu." 6 "D: Unskilled manu."
*label values class_head_grade LblClassGrade
global keepers1960 $keepers1960 class_husb_3cat

gen male = v10
recode male 1=1 2=0
global keepers1960 $keepers1960 male

gen married = v11
recode married 1=1 2=0 3=0 4=0
global keepers1960 $keepers1960 married

gen unionmem_resp = v199
recode unionmem_resp 1/5=1 8=0 0=0 9=. 0=.
global keepers1960 $keepers1960 unionmem_resp



// Pascal/SM moderators

foreach var of varlist   v90 v93 v94  v95 v96 {
        gen Z`var'=`var'
		replace Z`var'=1 if `var'==5
		replace Z`var'=2 if `var'==4
		replace Z`var'=3 if `var'==3 |`var'==8
		replace Z`var'=4 if `var'==2
		replace Z`var'=5 if `var'==1
		replace Z`var'=(Z`var'-1)/4
		tab Z`var' `var', m
}
 
rename Zv90 econ_control
lab var  econ_control "1=agree state control limit bank and industry influence"

rename Zv93 enc_saving
lab var enc_saving "1=agree with policies encouraging saving and free enterpise"

rename Zv94 group_equality
lab var group_equality "1=agree with group equality"

rename Zv95 imp_state_ressources
lab var imp_state_ressources "1=social security ressources more important then tax reduction"

rename Zv96 more_to_individual
lab var more_to_individual "1=more to individual via tax reduction"
  
foreach var of varlist   v35 v36 v37 v38 v39 v40 {
        gen Z`var'=`var'
		replace Z`var'=1 if `var'==4
		replace Z`var'=2 if `var'==3
		replace Z`var'=2.5 if `var'==8
		replace Z`var'=3 if `var'==2
		replace Z`var'=4 if `var'==1
		replace Z`var'=(Z`var'-1)/3
		tab Z`var' `var', m
}

rename Zv35 newspaper_sport
lab var newspaper_sport "1=read more sport articles"

rename Zv36 newspaper_politics
lab var newspaper_politics "1=read more politic articles"

rename Zv37 newspaper_family
lab var newspaper_family "1=read more family articles"

rename Zv38 newspaper_story
lab var newspaper_story "1=read more novel and short story articles"

rename Zv39 newspaper_international
lab var newspaper_international "1=read more international newsarticles"

rename Zv40 newspaper_crime
lab var newspaper_crime "1=read morecrime articles"

gen anti_newspaper_family=.
replace anti_newspaper_family=0.3333333 if newspaper_family>0.5 & newspaper_family<1
replace anti_newspaper_family=0.6666666 if newspaper_family>0 & newspaper_family<0.5
replace anti_newspaper_family=1 if newspaper_family==0
replace anti_newspaper_family=0.5 if newspaper_family==0.5
replace anti_newspaper_family=0 if newspaper_family==1

foreach var of varlist  econ_control group_equality imp_state_ressources {
        gen anti_`var'=.
		replace anti_`var'=1 if `var'==0
		replace anti_`var'=0.75 if `var'==0.25
		replace anti_`var'=0.5 if `var'==0.5
		replace anti_`var'=0.25 if `var'==0.75
		replace anti_`var'=0 if `var'==1
		tab anti_`var' `var', m
}

gen index_interest=( gpi  +newspaper_politics +anti_newspaper_family+ newspaper_story +newspaper_international+ newspaper_crime  )/6
global keepers1960 $keepers1960 index_interest

gen index_market_oriented=(socref +anti_econ_control +enc_saving +anti_group_equality+ anti_imp_state_ressources+ more_to_individual)/6
global keepers1960 $keepers1960 index_market_oriented

